from base import Base
from selenium.webdriver.common.by import By
from time import sleep


#定义页面类，继承基类
class GouWuChePage(Base):

    #购物图标
    gouwuche = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout[2]/android.widget.HorizontalScrollView/android.widget.LinearLayout/android.widget.LinearLayout[4]/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.ImageView')
    #结算按钮
    jiesuan = 'new UiSelector().resourceId("com.achievo.vipshop:id/cart_native_submit_layout")'


    #断言
    dy = (By.XPATH,'//android.widget.TextView[@resource-id="com.achievo.vipshop:id/vipheader_title_view_b"]')


    def gouwucheyewu(self):
        self.find_ele(self.gouwuche).click()
        sleep(2)
        self.find_ele(self.jiesuan).click()
        sleep(2)

    #定位 勾选商品
    gouxuanshangpin = (By.XPATH,'(//android.widget.ImageView[@content-desc="未勾选"])[1]')

    #同意
    dy_tongyi = (By.ID,'com.achievo.vipshop:id/main_button_style_1')

    def jiesuanyewu(self):
        self.find_ele(self.gouwuche).click()
        sleep(2)
        self.find_ele(self.gouxuanshangpin).click()
        sleep(2)
        self.find_ele(self.jiesuan).click()
        sleep(2)
